package com.suntront.lib_db.table;

import android.text.TextUtils;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import com.suntront.lib_db.utils.FileUtils;
import com.suntront.lib_db.utils.Utils;

import java.io.Serializable;

/**
 * Created by MSI1 on 2017/3/2.
 */
@Entity(tableName = "UserT")
public class UserT implements Serializable {

    /**
     * 用户ID(UserInfoId)
     * 用户编号(UserInfoCode)
     * 用户姓名(UserName)
     * 用户地址(UserAddress)
     * 联系方式(contect)
     * 用户状态(Userstate) 1:通水 8：停水
     * 上月止度(LastNumber)
     * 本月止度(CurrNum)
     * 当月用水量(CurrWaterNum)
     * 追加量(AddFlow)
     * 估值图片(GuessImage)
     * 估值原因(GuessReason)
     * 3月平均(ThreeAverage)
     * 欠款笔数(ArrearsCount)
     * 欠款总额(SumMoney)
     * 抄表时间(WriteMeterDate)
     * 最新抄表年份（year）
     * 最新抄表月份（month）
     * 抄表状态(WriteMeterState) 1：已抄  2：未抄  3：估抄
     * 是否上传(IsUpLoad)
     * 是否需要上传用户混合用水信息(isUpUserInfo)
     * 册本ID(RosterId)
     * 册本编号(RosterCode)
     * 册本名称(RosterName)
     * 水表ID(MeterInfoId)
     * 水表编号(MeterCode)
     * 水表地址(MeterWallAddress)
     * 用水性质ID(MixWaterTypeId)
     * 混合用水类型(MixWaterType)0：无  1：定比 2：定量
     * 混合用水定比比例(MixWaterRate)
     * 混合用水定量值(MixWaterFlow)
     * 用户用水类型名称(UserWaterTypeName)
     * 备注(Remark)
     * 表井ID(WellId)
     * 表井编号(WellCode)
     * 表井名称(WellName)
     * 表井地址(WellAddress)
     * 坐标（Corrdinate）
     * NFC标签（nfcTag）
     */
    @PrimaryKey(autoGenerate = true)
    private int id;
    @ColumnInfo(name = "MeterDataCurrentMonthId")
    private int MeterDataCurrentMonthId;
    @ColumnInfo(name = "userInfoId")
    private int userInfoId;
    @ColumnInfo(name = "userInfoCode")
    private String userInfoCode;
    @ColumnInfo(name = "userName")
    private String userName;
    @ColumnInfo(name = "userAddress")
    private String userAddress;
    @ColumnInfo(name = "userState")
    private int userState;
    @ColumnInfo(name = "lastNumber")
    private int lastNumber;
    @ColumnInfo(name = "currNumber")
    private int currNumber;
    @ColumnInfo(name = "currWaterNumber")
    private int currWaterNumber;
    @ColumnInfo(name = "addFlow")
    private int addFlow;
    @ColumnInfo(name = "guessImage")
    private String guessImage;
    @ColumnInfo(name = "guessReason")
    private String guessReason;
    @ColumnInfo(name = "threeAverage")
    private float threeAverage;
    @ColumnInfo(name = "arrearsCount")
    private int arrearsCount;
    @ColumnInfo(name = "sumMoney")
    private float sumMoney;
    @ColumnInfo(name = "writeMeterDate")
    private String writeMeterDate;
    @ColumnInfo(name = "year")
    private int year;
    @ColumnInfo(name = "month")
    private int month;
    @ColumnInfo(name = "writeMeterState")
    private int writeMeterState;
    @ColumnInfo(name = "isUpLoad")
    private Boolean isUpLoad;
    @ColumnInfo(name = "isUpUserInfo")
    private Boolean isUpUserInfo;
    @ColumnInfo(name = "rosterId")
    private int rosterId;
    @ColumnInfo(name = "rosterCode")
    private String rosterCode;
    @ColumnInfo(name = "rosterName")
    private String rosterName;
    @ColumnInfo(name = "meterInfoId")
    private int meterInfoId;
    @ColumnInfo(name = "meterCode")
    private String meterCode;
    @ColumnInfo(name = "meterWallAddress")
    private String meterWallAddress;
    @ColumnInfo(name = "mixWaterTypeId")
    private int mixWaterTypeId;
    @ColumnInfo(name = "mixWaterType")
    private int mixWaterType;
    @ColumnInfo(name = "mixWaterRate")
    private float mixWaterRate;
    @ColumnInfo(name = "mixWaterFlow")
    private int mixWaterFlow;
    @ColumnInfo(name = "userWaterTypeName")
    private String userWaterTypeName;
    @ColumnInfo(name = "remark")
    private String remark;
    @ColumnInfo(name = "WellId")
    private String WellId;
    @ColumnInfo(name = "wellCode")
    private String wellCode;
    @ColumnInfo(name = "wellName")
    private String wellName;
    @ColumnInfo(name = "wellAddress")
    private String wellAddress;
    @ColumnInfo(name = "Corrdinate")
    private String Corrdinate;
    @ColumnInfo(name = "Contect")
    private String Contect;
    @ColumnInfo(name = "sealNumber")
    private String sealNumber;//铅封号
    @ColumnInfo(name = "userType")
    private int userType;
    @ColumnInfo(name = "metercal")
    private int metercal;
    @ColumnInfo(name = "Ismakebill")
    private int Ismakebill;
    @ColumnInfo(name = "MARK")
    private String MARK;
    @ColumnInfo(name = "rosterOrder")
    private int rosterOrder;
    @ColumnInfo(name = "collectionMoney")  //代收金额
    private int collectionMoney;
    @ColumnInfo(name = "personId")
    private String personId;
    @ColumnInfo(name = "printContent")
    private String printContent;
    @ColumnInfo(name = "isDown")//抄表员id
    private boolean isDown;
    boolean hasFocus = false;

    @ColumnInfo(name = "unreadReasonId")  //未抄原因id
    private int unreadReasonId;
    @ColumnInfo(name = "unreadReasonName") // 未抄原因名称
    private String unreadReasonName;

    public String getPrintContent() {
        return printContent;
    }

    public void setPrintContent(String printContent) {
        this.printContent = printContent;
    }

    public int getMeterDataCurrentMonthId() {
        return MeterDataCurrentMonthId;
    }

    public void setMeterDataCurrentMonthId(int meterDataCurrentMonthId) {
        MeterDataCurrentMonthId = meterDataCurrentMonthId;
    }

    public int getCollectionMoney() {
        return collectionMoney;
    }

    public void setCollectionMoney(int collectionMoney) {
        this.collectionMoney = collectionMoney;
    }

    public int getRosterOrder() {
        return rosterOrder;
    }

    public void setRosterOrder(int rosterOrder) {
        this.rosterOrder = rosterOrder;
    }

    public boolean isHasFocus() {
        return hasFocus;
    }

    public void setHasFocus(boolean hasFocus) {
        this.hasFocus = hasFocus;
    }

    public int getIsmakebill() {
        return Ismakebill;
    }

    public void setIsmakebill(int ismakebill) {
        Ismakebill = ismakebill;
    }

    public boolean isDown() {
        return isDown;
    }

    public void setDown(boolean down) {
        isDown = down;
    }

    public int getMetercal() {
        return metercal;
    }

    public void setMetercal(int metercal) {
        this.metercal = metercal;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getMark() {
        return MARK;
    }

    public void setMark(String MARK) {
        this.MARK = MARK;
    }

    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    public String getSealNumber() {
        return sealNumber;
    }

    public void setSealNumber(String sealNumber) {
        this.sealNumber = sealNumber;
    }

    public String getContect() {
        return Contect;
    }

    public void setContect(String contect) {
        Contect = contect;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getUserInfoId() {
        return userInfoId;
    }

    public void setUserInfoId(int userInfoId) {
        this.userInfoId = userInfoId;
    }

    public String getUserInfoCode() {
        return userInfoCode;
    }

    public void setUserInfoCode(String userInfoCode) {
        this.userInfoCode = userInfoCode;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserAddress() {
        return userAddress;
    }

    public void setUserAddress(String userAddress) {
        this.userAddress = userAddress;
    }

    public int getUserState() {
        return userState;
    }

    public void setUserState(int userState) {
        this.userState = userState;
    }

    public int getLastNumber() {
        return lastNumber;
    }

    public void setLastNumber(int lastNumber) {
        this.lastNumber = lastNumber;
    }

    public int getCurrNumber() {
        return currNumber;
    }

    public void setCurrNumber(int currNumber) {
        this.currNumber = currNumber;
    }

    public int getCurrWaterNumber() {
        return currWaterNumber;
    }

    public void setCurrWaterNumber(int currWaterNumber) {
        this.currWaterNumber = currWaterNumber;
    }

    public int getAddFlow() {
        return addFlow;
    }

    public void setAddFlow(int addFlow) {
        this.addFlow = addFlow;
    }

    public String getGuessImage() {
        return guessImage;
    }

    public void setGuessImage(String guessImage) {
        this.guessImage = guessImage;
    }

    public String getGuessReason() {
        return guessReason;
    }

    public void setGuessReason(String guessReason) {
        this.guessReason = guessReason;
    }

    public float getThreeAverage() {
        return threeAverage;
    }

    public void setThreeAverage(float threeAverage) {
        this.threeAverage = threeAverage;
    }

    public int getArrearsCount() {
        return arrearsCount;
    }

    public void setArrearsCount(int arrearsCount) {
        this.arrearsCount = arrearsCount;
    }

    public float getSumMoney() {
        return sumMoney;
    }

    public void setSumMoney(float sumMoney) {
        this.sumMoney = sumMoney;
    }

    public String getWriteMeterDate() {
        return writeMeterDate;
    }

    public void setWriteMeterDate(String writeMeterDate) {
        this.writeMeterDate = writeMeterDate;
    }

    public int getWriteMeterState() {
        return writeMeterState;
    }

    public void setWriteMeterState(int writeMeterState) {
        this.writeMeterState = writeMeterState;
    }

    public Boolean getUpLoad() {
        return isUpLoad;
    }

    public void setUpLoad(Boolean upLoad) {
        isUpLoad = upLoad;
    }

    public Boolean getUpUserInfo() {
        return isUpUserInfo;
    }

    public void setUpUserInfo(Boolean upUserInfo) {
        isUpUserInfo = upUserInfo;
    }

    public int getRosterId() {
        return rosterId;
    }

    public void setRosterId(int rosterId) {
        this.rosterId = rosterId;
    }

    public String getRosterCode() {
        return rosterCode;
    }

    public void setRosterCode(String rosterCode) {
        this.rosterCode = rosterCode;
    }

    public String getRosterName() {
        return rosterName;
    }

    public void setRosterName(String rosterName) {
        this.rosterName = rosterName;
    }

    public int getMeterInfoId() {
        return meterInfoId;
    }

    public void setMeterInfoId(int meterInfoId) {
        this.meterInfoId = meterInfoId;
    }

    public String getMeterCode() {
        return meterCode;
    }

    public void setMeterCode(String meterCode) {
        this.meterCode = meterCode;
    }

    public String getMeterWallAddress() {
        return meterWallAddress;
    }

    public void setMeterWallAddress(String meterWallAddress) {
        this.meterWallAddress = meterWallAddress;
    }

    public int getMixWaterTypeId() {
        return mixWaterTypeId;
    }

    public void setMixWaterTypeId(int mixWaterTypeId) {
        this.mixWaterTypeId = mixWaterTypeId;
    }

    public int getMixWaterType() {
        return mixWaterType;
    }

    public void setMixWaterType(int mixWaterType) {
        this.mixWaterType = mixWaterType;
    }

    public float getMixWaterRate() {
        return mixWaterRate;
    }

    public void setMixWaterRate(float mixWaterRate) {
        this.mixWaterRate = mixWaterRate;
    }

    public int getMixWaterFlow() {
        return mixWaterFlow;
    }

    public void setMixWaterFlow(int mixWaterFlow) {
        this.mixWaterFlow = mixWaterFlow;
    }

    public String getUserWaterTypeName() {
        return userWaterTypeName;
    }

    public void setUserWaterTypeName(String userWaterTypeName) {
        this.userWaterTypeName = userWaterTypeName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getWellId() {
        return WellId;
    }

    public void setWellId(String wellId) {
        WellId = wellId;
    }

    public String getWellCode() {
        return wellCode;
    }

    public void setWellCode(String wellCode) {
        this.wellCode = wellCode;
    }

    public String getWellName() {
        return wellName;
    }

    public void setWellName(String wellName) {
        this.wellName = wellName;
    }

    public String getWellAddress() {
        return wellAddress;
    }

    public void setWellAddress(String wellAddress) {
        this.wellAddress = wellAddress;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public String getCorrdinate() {
        return Corrdinate;
    }

    public void setCorrdinate(String corrdinate) {
        Corrdinate = corrdinate;
    }

    public int getUnreadReasonId() {
        return unreadReasonId;
    }

    public void setUnreadReasonId(int unreadReasonId) {
        this.unreadReasonId = unreadReasonId;
    }

    public String getUnreadReasonName() {
        return unreadReasonName;
    }

    public void setUnreadReasonName(String unreadReasonName) {
        this.unreadReasonName = unreadReasonName;
    }

    public String getMARK() {
        return MARK;
    }

    public void setMARK(String MARK) {
        this.MARK = MARK;
    }

    @Override
    public String toString() {
        String imagestr = "";
        String base64 = "";
        if (!TextUtils.isEmpty(guessImage)) {
            if (guessImage.contains("&")) {
                int indexOf = guessImage.lastIndexOf("&");
                imagestr = guessImage.substring(indexOf + 1);
            } else {
                imagestr = guessImage;
            }
        }
        if (!TextUtils.isEmpty(imagestr)) {
            String s = Utils.compressImage(imagestr, imagestr, 80);
            if (!TextUtils.isEmpty(FileUtils.imgToBase64(s))) {
                base64 = "data:image/png;base64," + FileUtils.imgToBase64(s);
            }
        }

        return "[{" +
                "\"" + "MeterDataCurrentMonthId" + "\"" + ":" + MeterDataCurrentMonthId +
                ",\"" + "NewMixWaterTypeId" + "\"" + ":" + mixWaterTypeId +
                ",\"" + "NewMixWaterType" + "\"" + ":" + mixWaterType +
                ",\"" + "NewMixWaterRate" + "\"" + ":" + 0 +
                ",\"" + "NewMixWaterFlow" + "\"" + ":" + mixWaterFlow +
                ",\"" + "UserInfoId" + "\"" + ":" + userInfoId +
                ",\"" + "RosterId" + "\"" + ":" + rosterId +
                ",\"" + "MeterInfoId" + "\"" + ":" + meterInfoId +
                ",\"" + "WellId" + "\"" + ":" + "\"" + WellId + "\"" +
                ",\"" + "LastNumber" + "\"" + ":" + lastNumber +
                ",\"" + "CurrNum" + "\"" + ":" + currNumber +
                ",\"" + "ReadMeterDate" + "\"" + ":" + "\"" + writeMeterDate + "\"" +
                ",\"" + "DataYear" + "\"" + ":" + year +
                ",\"" + "DataMonth" + "\"" + ":" + month +
                ",\"" + "ReadMeterState" + "\"" + ":" + writeMeterState +
                ",\"" + "CurrWaterNum" + "\"" + ":" + currWaterNumber +
                ",\"" + "IsUpLoad" + "\"" + ":" + 1 +
                ",\"" + "Image" + "\"" + ":" + "\"" + base64 + "\"" +
                ",\"" + "Remark" + "\"" + ":" + "\"" + guessReason + "\"" +
                ",\"" + "WellAdd" + "\"" + ":" + "\"" + wellAddress + "\"" +
                ",\"" + "Corrdinate" + "\"" + ":" + "\"" + Corrdinate + "\"" +
                ",\"" + "AddFlow" + "\"" + ":" + addFlow +
                ",\"" + "USERTYPE" + "\"" + ":" + userType +
                ",\"" + "Contect" + "\"" + ":" + "\"" + Contect + "\"" +
                ",\"" + "UserAddress" + "\"" + ":" + "\"" + userAddress + "\"" +
                ",\"" + "SealNumber" + "\"" + ":" + "\"" + sealNumber + "\"" +
                ",\"" + "MeterreaderId" + "\"" + ":" + "\"" + personId + "\"" +
                ",\"" + "UserRemark" + "\"" + ":" + "\"" + MARK + "\"" +
                ",\"" + "PhoneType" + "\"" + ":" + "\"" + "Android" + "\"" +
                ",\"" + "UnreadReasonId" + "\"" + ":" + "\"" + unreadReasonId + "\"" +
                ",\"" + "UnreadReasonName" + "\"" + ":" + "\"" + unreadReasonName + "\"" +
                "}]";
    }

    public String toSiginString() {
        String imagestr = "";
        String base64 = "";
        if (!TextUtils.isEmpty(guessImage)) {
            if (guessImage.contains("&")) {
                int indexOf = guessImage.lastIndexOf("&");
                imagestr = guessImage.substring(indexOf + 1);
            } else {
                imagestr = guessImage;
            }
        }
        if (!TextUtils.isEmpty(imagestr)) {
            String s = Utils.compressImage(imagestr, imagestr, 80);
            if (!TextUtils.isEmpty(FileUtils.imgToBase64(s))) {
                base64 = "data:image/png;base64," + FileUtils.imgToBase64(s);
            }
        }

        return "{" +
                "\"" + "MeterDataCurrentMonthId" + "\"" + ":" + MeterDataCurrentMonthId +
                ",\"" + "NewMixWaterTypeId" + "\"" + ":" + mixWaterTypeId +
                ",\"" + "NewMixWaterType" + "\"" + ":" + mixWaterType +
                ",\"" + "NewMixWaterRate" + "\"" + ":" + 0 +
                ",\"" + "NewMixWaterFlow" + "\"" + ":" + mixWaterFlow +
                ",\"" + "UserInfoId" + "\"" + ":" + userInfoId +
                ",\"" + "RosterId" + "\"" + ":" + rosterId +
                ",\"" + "MeterInfoId" + "\"" + ":" + meterInfoId +
                ",\"" + "WellId" + "\"" + ":" + "\"" + WellId + "\"" +
                ",\"" + "LastNumber" + "\"" + ":" + lastNumber +
                ",\"" + "CurrNum" + "\"" + ":" + currNumber +
                ",\"" + "ReadMeterDate" + "\"" + ":" + "\"" + writeMeterDate + "\"" +
                ",\"" + "DataYear" + "\"" + ":" + year +
                ",\"" + "DataMonth" + "\"" + ":" + month +
                ",\"" + "ReadMeterState" + "\"" + ":" + writeMeterState +
                ",\"" + "CurrWaterNum" + "\"" + ":" + currWaterNumber +
                ",\"" + "IsUpLoad" + "\"" + ":" + 1 +
                ",\"" + "Image" + "\"" + ":" + "\"" + base64 + "\"" +
                ",\"" + "Remark" + "\"" + ":" + "\"" + guessReason + "\"" +
                ",\"" + "WellAdd" + "\"" + ":" + "\"" + wellAddress + "\"" +
                ",\"" + "Corrdinate" + "\"" + ":" + "\"" + Corrdinate + "\"" +
                ",\"" + "AddFlow" + "\"" + ":" + addFlow +
                ",\"" + "USERTYPE" + "\"" + ":" + userType +
                ",\"" + "Contect" + "\"" + ":" + "\"" + Contect + "\"" +
                ",\"" + "UserAddress" + "\"" + ":" + "\"" + userAddress + "\"" +
                ",\"" + "SealNumber" + "\"" + ":" + "\"" + sealNumber + "\"" +
                ",\"" + "MeterreaderId" + "\"" + ":" + "\"" + personId + "\"" +
                ",\"" + "UserRemark" + "\"" + ":" + "\"" + MARK + "\"" +
                ",\"" + "PhoneType" + "\"" + ":" + "\"" + "Android" + "\"" +
                ",\"" + "UnreadReasonId" + "\"" + ":" + "\"" + unreadReasonId + "\"" +
                ",\"" + "UnreadReasonName" + "\"" + ":" + "\"" + unreadReasonName + "\"" +
                "}";
    }

    public String toUserjson() {
        return "[{" +
                "\"" + "UserInfoID" + "\"" + ":" + userInfoId +
                ",\"" + "mixwatertypeid" + "\"" + ":" + mixWaterTypeId +
                ",\"" + "mixwatertype" + "\"" + ":" + mixWaterType +
                ",\"" + "mixwaterrate" + "\"" + ":" + mixWaterRate +
                ",\"" + "mixwaterflow" + "\"" + ":" + mixWaterFlow +
                ",\"" + "remark" + "\"" + ":" + "\"" + remark + "\"" +
                "}]";
    }

    public String toUserOrderjson() {
        return "{" +
                "\"" + "meterInfoId" + "\"" + ":" + meterInfoId +
                ",\"" + "rosterOrder" + "\"" + ":" + rosterOrder +
                "}";
    }
}
